<template>
  <div class="wrapper">
    <minbar title="我的订单" :isPadding="true">
    </minbar>
    <!-- 顶部的tab页 -->
    <x-toptab :tabTitles="tabTitles" @itemClick="tabItemClick"></x-toptab>
    <x-list ref="clist" :config="configData" :param="orderParam" @receiveData="receiveData">
      <div slot="content">
        <orderpage 
          :listData="listData" 
          :showDetail="true"
          @showDetailClick="showDetailClick"></orderpage>
      </div>
    </x-list>
  </div>
</template>

<script>
import asCore from "../../../common/js/core";
import listData from "./data/orderData";
const navigator = weex.requireModule('navigator');
export default { 
  components: {
    "minbar" : require("../../../common/component/minbar.vue"),
    "x-toptab" : require("../../../common/component/toptab.vue"),
    "x-list": require("../../../common/component/list.vue"),
    "orderpage" : require("./comp/orderPage.vue"),
  },
  data() {
    return {
      currentType:"all",
      tabTitles:[{
          title:"全部",
          code:"all"
        },
        {
          title:"待付款",
          code:"dfk"
        },
        {
          title:"待发货",
          code:"dfh"
        },
        {
          title:"待签收",
          code:"dqs"
      }],
      /**数据action配置 */
      configData:{
        pageRow:{
          page:1,
          limit:10
        },
        action:"/member/order/list"
      },
      /**订单配置 */
      orderParam:{
        status:0
      },
      /**订单数据 */
      listData:[]
    };
  },
  methods: {
    /**类型点击 */
    tabItemClick(code,index){
        this.currentType = code;
        this.$nextTick(()=>{
          this.getListData();
        });
    },
    /**接收参数 */
    receiveData(type,data){
      if(type=="refresh"){
        this.listData = data;
      }else{
        this.listData.push(...data);
      }
    },
    /**接收 */
    getListData(){
      if(this.currentType=="all"){
        this.orderParam.status = null;
      }else if(this.currentType=="dfk"){
        this.orderParam.status = 1;
      }else if(this.currentType=="dfh"){
        this.orderParam.status = 3;
      }else if(this.currentType=="dqs"){
        this.orderParam.status = 5;
      }
      this.$nextTick(()=>{
          this.$refs.clist.refreshData();
      });
      
    },
    /**打开详情 */
    showDetailClick(shopData){
      navigator.pushParam(asCore.localpath + 'tailor/app/myinfo/orderInfo.js',{
          sno:shopData.sn
        }
      );
    }
  }
};
</script>
<style scoped>
.iconfont {
    font-family:iconfont;
}
.wrapper {
  background-color: #dedfe1;
}
</style>

